package com.uhu.code;

import com.uhu.code.help.ListNode;

import java.util.ArrayList;
import java.util.List;

/**
 * 141.环形链表
 * https://leetcode.cn/problems/linked-list-cycle/description/?envType=study-plan-v2&envId=top-100-liked
 */
public class Solution141 {
    public boolean hasCycle(ListNode head) {
        List<ListNode> recordList = new ArrayList<>();
        while(true) {
            if(head == null) {
                return false;
            }
            if(recordList.contains(head)) {
                return true;
            }else {
                recordList.add(head);
            }
            head = head.next;
        }
    }
}
